<template>
	<div class="goods_four">
		<div class="goods-list" id="goods-list">
			<div class="good bordertop-1px" v-for="(goods, index) in goodsList">
				<div class="cl-c-left" @click="getSelect($event,index)" v-show="!isEdit">
					<input type="checkbox" :checked="nums.indexOf(index)>=0" name="checkboxinput" :class="{active: nums.indexOf(index)<0}"
					 class="input-checkbox">
					<i class="iconfont">&#xe6ad;</i>
				</div>
				<div class="goods-left" @click="goDetail(goods)">
					<img v-lazy="goods.image" :key="goods.image" />
				</div>
				<div class="goods-right" @click="goDetail(goods)">
					<p class="two-line"><span class="TBimg" v-show="goods.is_tmall == 0"></span><span class="TMimg" v-show="goods.is_tmall == 1"></span>{{goods.title}}</p>
					<div class="gr-sale">
						<p>原价：<span>￥{{goods.origin_price}}</span></p>
						<p>{{goods.itemsale || 0}}人已买</p>
					</div>
					<div class="gr-price">
						<div class="gr-price-left">
							<i class="icon" :style="{backgroundImage: 'linear-gradient(to right, rgb(79, 92, 104), rgb(42, 62, 69))',background: 'linear-gradient(to right,' + colorLeft + ',' + colorRight + ')'}">券后价</i>
							<label><span>￥</span>{{goods.coupon_price}}</label>
						</div>
						<div class="gr-price-right" :style="{backgroundImage: 'linear-gradient(to right, rgb(79, 92, 104), rgb(42, 62, 69))',background: 'linear-gradient(to right,' + colorLeft + ',' + colorRight + ')'}">
							{{goods.quan_price}}元券
							<div class="dotl"></div>
							<div class="dotr"></div>
						</div>
					</div>
				</div>
			</div>
			<div class="goods-none" v-if="goodsList.length == 0">
				<img src="../assets/img/nodata.png" />
			</div>
		</div>
	</div>
</template>
<script>
	import {
		Toast
	} from 'mint-ui'
	import axios from 'axios'
	import Http from '../http.js'
	export default {
		props: {
			goodsList: {
				type: Array
			},
			isEdit: {
				type: Boolean
			},
			nums: {
				type: Array
			}
		},
		data() {
			return {
				isCheckedAll: true,
				colorLeft: window.localStorage.getItem("left"),
				colorRight: window.localStorage.getItem("right"),
				colorMid: window.localStorage.getItem("mid"),
				token: window.localStorage.getItem("token"),
			}
		},
		mounted() {},
		methods: {
			goDetail: function(goods) {
				if (goods.is_tmall == 1) {
					this.type = 1;
					this.$router.push({
						path: '/product/detail/' + goods.origin_id,
						query: {
							type: this.type,
							is_collect: 1,
							image: goods.image,
							title: goods.title,
							coupon_price: goods.coupon_price,
							origin_price: goods.origin_price,
							quan_price: goods.quan_price,
							sub_title: goods.sub_title,
							quan_time: goods.quan_time,
						}
					})
				} else if (goods.is_tmall == 0) {
					this.type = 2;
					this.$router.push({
						path: '/product/detail/' + goods.origin_id,
						query: {
							type: this.type,
							is_collect: 1,
							image: goods.image,
							title: goods.title,
							coupon_price: goods.coupon_price,
							origin_price: goods.origin_price,
							quan_price: goods.quan_price,
							sub_title: goods.sub_title,
							quan_time: goods.quan_time,
						}
					})
				}
			},
			getSelect: function(e, index) {
				let idIndex = this.nums.indexOf(index)
				if (idIndex >= 0) { //如果已经包含就去除
					this.nums.splice(idIndex, 1)
				} else { //如果没有包含就添加
					this.nums.push(index)
				}
			},
		}
	}
</script>
<style lang="scss" scoped>
	.goods_four {
		@import '../assets/common/common.scss'
	}
</style>
